import { Field } from "@prisma/client";

type Map = Record<string, Field>;

const Universality = [1, 4, 5, 6];

export const getter = (field: Map, key: string, value: unknown) => {
  const node = field[key];
  if (!node) return value;
  if (!node.subkind) return value;
  if (!value) return value;
  if (Universality.includes(node.subkind)) return value;

  if (node.subkind === 2) {
    if (!node.subjsonstr) return value;
    if (typeof value !== "number") return value;
    return node.subjsonstr[value];
  }

  console.log(node);
};
